package cz.muni.fi.hauntedhouses.service.impl;

import cz.muni.fi.hauntedhouses.dao.SkillDAO;
import cz.muni.fi.hauntedhouses.service.SkillService;
import cz.muni.fi.hauntedhouses.to.SkillTO;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 *
 * @author Wendy
 */
@Service
@Transactional
public class SkillServiceImpl implements SkillService {

    @Autowired
    private SkillDAO skillDao;
    
    @Override
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public void create(SkillTO skillTo) {
            skillDao.create(skillTo);
    }

    @Override
    public SkillTO get(Long id) {        
        return skillDao.get(id);
    }

    @Override
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public void update(SkillTO skill) {
        skillDao.update(skill);
    }

    @Override
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public void delete(SkillTO skill) {
        skillDao.delete(skill);
    }

    @Override
    public List<SkillTO> findAll() {
        return skillDao.findAll();
    }

    @Override
    public SkillTO findByName(String name) {
        return skillDao.findByName(name);
    }
    
}
